package com.megagoodsoftware.MediaShare.fakes;

import org.apache.http.client.*;
import org.apache.http.client.methods.*;
import org.json.*;

import com.megagoodsoftware.smugmug.*;
import com.megagoodsoftware.smugmug.exceptions.*;

public class FakeSmugMugClient extends SmugMugClient {
	private Exception exception;
	
	public FakeSmugMugClient(HttpClient connectionClient, Exception e) {
		this(connectionClient);
		this.exception = e;
	}
	
	public FakeSmugMugClient(HttpClient connectionClient) {
		setClient(connectionClient);
	}

	public HttpPut getHttpPut() {
		return super.getHttpPut();
	}
	public void setInvalidSession(boolean invalid)
	{
		((FakeHttpClient)getClient()).setInvalidSession(invalid);
	}
	public void setSuccessResponse()
	{
		((FakeHttpClient)getClient()).setSuccessResponseMap();
	}
	public void setFailureResponse()
	{
		((FakeHttpClient)getClient()).setFailureResponseMap();
	}

	@Override
    protected JSONObject connect(String url) throws SmugMugInternalError, SmugMugFailedResponse, SmugMugInvalidSession
	{
		if (exception == null)
			return super.connect(url);
		else if (exception instanceof SmugMugInternalError)
			throw (SmugMugInternalError)exception;
		else if (exception instanceof SmugMugFailedResponse)
			throw (SmugMugFailedResponse)exception;
		else
			throw new SmugMugInternalError("unknown exception");
	}

}
